#include<stdio.h>
#include<unistd.h>
#include<sys/wait.h>
#include<stdlib.h>
#include<sys/types.h>
int main()
{
    pid_t id=fork();
    if(id==0)
    {
        //child
        printf("I am child pid=%d ppid=%d\n",getpid(),getppid());

        execl("/usr/bin/ls","ls","-l",NULL);//最后必须加NULL结束
        
        printf("我是子进程后续\n");
        exit(1);
    }
    int status=0;
    pid_t ret=waitpid(-1,&status,0);
    if(ret>0)
    {
        printf("waitpid success\n");
        printf("exitcode=%d\n",(status>>8)&0xFF);
    }
    else{
        printf("等待失败\n");
    }
    return 0;
}
